#include <tiredis/UnboundedBuffer.h>
#include <tiredis/Statistics.h>
#include <tiredis/Common.h>

Error info(const std::vector<std::string>& params, UnboundedBuffer* reply)
{
    std::string infoStr;

    char buf[32];
    snprintf(buf, sizeof buf - 1, "%lu", g_stat->totalRC_.load());
    infoStr.append("total.request.count: ");
    infoStr.append(buf);
    infoStr.append("\r\n");
    snprintf(buf, sizeof buf - 1, "%lu", g_stat->getRC_.load());
    infoStr.append("get.request.count: ");
    infoStr.append(buf);
    infoStr.append("\r\n");
    snprintf(buf, sizeof buf - 1, "%lu", g_stat->setRC_.load());
    infoStr.append("set.request.count: ");
    infoStr.append(buf);
    infoStr.append("\r\n");
    snprintf(buf, sizeof buf - 1, "%lu", g_stat->scanRC_.load());
    infoStr.append("scan.request.count: ");
    infoStr.append(buf);
    infoStr.append("\r\n");
    snprintf(buf, sizeof buf - 1, "%llu", g_stat->totalResponseTime_.load());
    infoStr.append("total_response_time.request.count: ");
    infoStr.append(buf);
    infoStr.append("\r\n");
    FormatBulk(infoStr, reply);
    return Error_ok;
}
